package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 退款附件信息
 */
@TableName("t_revoke_order_attachment")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.RevokeOrderAttachmentMapper")
public class RevokeOrderAttachmentDO extends BaseEntity {
    /**
     * 理赔主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long revokeOrderId;

    /**
     * 序号
     */
    @TableId(type = IdType.ID_WORKER)
    private Integer no;

    /**
     * 下载文件url地址
     */
    @TableField(value = "file_url")
    private String fileUrl;

    /**
     * 文件类型
     */
    @TableField(value = "file_type")
    private String fileType;

    /**
     * 文件路径
     */
    @TableField(value = "file_path")
    private String filePath;

    /**
     * 文件名称
     */
    @TableField(value = "file_name")
    private String fileName;

    /**
     * 文件md5值
     */
    @TableField(value = "file_md5")
    private String fileMd5;

    public RevokeOrderAttachmentVo buildVo() {
        return new RevokeOrderAttachmentVo(revokeOrderId, no, fileUrl, fileType, filePath, fileName, fileMd5);
    }

    public static RevokeOrderAttachmentDO of(RevokeOrderAttachmentVo vo) {
        return new RevokeOrderAttachmentDO(vo.getRevokeOrderId(), vo.getNo(), vo.getFileUrl(), vo.getFileType(), vo.getFilePath(), vo.getFileName(), vo.getFileMd5());
    }
}
